﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace GUI
{
    public partial class Masterdesign : Form
    {
        public Masterdesign()
        {
            InitializeComponent();
        }

        private void Form3_Load(object sender, EventArgs e)
        {

        }
        
        bool Active = false;
        int X = 0,Y=0;

        private void FlytForm_MouseDown(object sender,MouseEventArgs e)
        {
            Active = true;
            X = e.X;
            Y = e.Y;
        }
        private void FlytForm_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                this.Location = new Point(this.Left + e.X-X, this.Top + e.Y-Y);
                Refresh();
            }

        }
        private void FlytForm_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void LukKnap_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void MinKnap_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void MaxKnap_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }

        #region Rammestyring

        private void RammeE_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeE_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                this.Size = new Size(this.Width + e.Location.X, this.Height);
                this.Refresh();

            }
        }
        private void RammeE_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeG_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeG_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                this.Size = new Size(this.Width, this.Height + e.Y);
                this.Refresh();
            }
        }
        private void RammeG_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeF_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeF_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                this.Size = new Size(this.Width + e.X, this.Height + e.Y);
                this.Refresh();
            }
        }
        private void RammeF_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeA_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeA_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                this.Refresh();
                if (e.X < 0)
                {
                    this.Location = new Point(this.Left + e.X, this.Top);
                    this.Size = new Size(this.Width - e.X, this.Height);
                }
                else
                {
                    this.Size = new Size(this.Width - e.X, this.Height);
                    this.Location = new Point(this.Left + e.X, this.Top);
                }
                this.Refresh();
            }
        }
        private void RammeA_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeH_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeH_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                if (e.X < 0)
                {
                    this.Location = new Point(this.Left + e.Location.X, this.Top);
                    this.Size = new Size(this.Width - e.Location.X, this.Height + e.Location.Y);
                }
                else
                {
                    this.Size = new Size(this.Width - e.Location.X, this.Height + e.Location.Y);
                    this.Location = new Point(this.Left + e.Location.X, this.Top);
                }
                this.Refresh();
            }
        }
        private void RammeH_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeC_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeC_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                if (e.Y > 0)
                {
                    this.Size = new Size(this.Width, this.Height - e.Y);
                    this.Location = new Point(this.Left, this.Top + e.Y);
                }
                else
                {
                    this.Location = new Point(this.Left, this.Top + e.Y);
                    this.Size = new Size(this.Width, this.Height - e.Y);
                }
                this.Refresh();
            }
        }
        private void RammeC_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeD_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeD_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                if (e.Y < 0)
                {
                    this.Location = new Point(this.Left, this.Top + e.Y);
                    this.Size = new Size(this.Width + e.X, this.Height - e.Y);
                }
                else
                {
                    this.Size = new Size(this.Width + e.X, this.Height - e.Y);
                    this.Location = new Point(this.Left, this.Top + e.Y);
                }
                this.Refresh();
            }
        }
        private void RammeD_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }

        private void RammeB_MouseDown(object sender, MouseEventArgs e)
        {
            Active = true;
        }
        private void RammeB_MouseMove(object sender, MouseEventArgs e)
        {
            if (Active)
            {
                if (e.Y < 0 || e.X < 0)
                {
                    this.Location = new Point(this.Left + e.X, this.Top + e.Y);
                    this.Size = new Size(this.Width - e.X, this.Height - e.Y);
                }
                else
                {
                    this.Size = new Size(this.Width - e.X, this.Height - e.Y);
                    this.Location = new Point(this.Left + e.X, this.Top + e.Y);
                }
                this.Refresh();
            }
        }
        private void RammeB_MouseUp(object sender, MouseEventArgs e)
        {
            Active = false;
        }
        #endregion 
        private void toolStripTileBar_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

        private void toolStripLukKnap_Click(object sender, EventArgs e)
        {
            string message = "Du er ved at lukke SBS ned, alt data der ikke er gemt - vil blive tabt og kan ikke genskabes - ønsker du at forsætte ??";
            string caption = "ADVARSEL !!!";
            MessageBoxButtons buttons = MessageBoxButtons.YesNo;
            DialogResult result;
            MessageBoxIcon w = MessageBoxIcon.Warning;

            result = MessageBox.Show(message, caption, buttons,w);

            if (result == System.Windows.Forms.DialogResult.Yes)
            {

                this.Close();
            }


        }

        private void MessageBoxOptions(string p)
        {
            throw new NotImplementedException();
        }

        private void toolStripMin_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Minimized;
        }

        private void toolStripButtonMax_Click(object sender, EventArgs e)
        {
            this.WindowState = FormWindowState.Maximized;
        }
    }
}
